package net.shopxx.entity;

import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.OrderBy;

/**
 * 实体类 - 颜色
 */

@Entity
public class Properties extends BaseEntity {

	private static final long serialVersionUID = -6109590619136943215L;

	private String enumLable;// 枚举标签

	private List<PropertiesValue> propertiesValueList;

	private ProductSize productSize;

	private Set<ProductProperties> productProperties;// 名称

	private Set<ProductCategory> productCategorySet;

	private Set<Productitem> productitemSet;

	
	public Properties()
	{
		
	}
	
	public Properties(String id)
	{
		super.setId(id);
	}
	
	@Column(nullable = false)
	public String getEnumLable() {
		return enumLable;
	}

	public void setEnumLable(String enumLable) {
		this.enumLable = enumLable;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "properties")
	public Set<ProductProperties> getProductProperties() {
		return productProperties;
	}

	public void setProductProperties(Set<ProductProperties> productProperties) {
		this.productProperties = productProperties;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "properties")
	@Cascade(value = { CascadeType.ALL})
	@OrderBy(clause = "modifyDate desc")
	public List<PropertiesValue> getPropertiesValueList() {
		return propertiesValueList;
	}

	public void setPropertiesValueList(List<PropertiesValue> propertiesValueList) {
		this.propertiesValueList = propertiesValueList;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "properties")
	public ProductSize getProductSize() {
		return productSize;
	}

	public void setProductSize(ProductSize productSize) {
		this.productSize = productSize;
	}

	@ManyToMany(fetch = FetchType.LAZY,mappedBy="propertiesSet")
	@Cascade(value = { CascadeType.DELETE,CascadeType.SAVE_UPDATE})
	public Set<ProductCategory> getProductCategorySet() {
		return productCategorySet;
	}

	public void setProductCategorySet(Set<ProductCategory> productCategorySet) {
		this.productCategorySet = productCategorySet;
	}

	@OneToMany(fetch = FetchType.LAZY)
	public Set<Productitem> getProductitemSet() {
		return productitemSet;
	}

	public void setProductitemSet(Set<Productitem> productitemSet) {
		this.productitemSet = productitemSet;
	}

	public int hashCode() {
		return getId().hashCode();
	}

}